package com.example.zhang.controller;

import com.example.zhang.service.BjService;
import com.example.zhang.service.impl.BjServiceImpl;
import com.example.zhang.vo.Bj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/bj")
public class BjController {

    @Autowired
    private BjService bjService;

    @RequestMapping("/query")
    private Map<String,Object> queryAll()
    {
        Map<String,Object> modelMap = new HashMap<String,Object>();
        List<Bj> lb = bjService.queryAll();
        modelMap.put("BjList",lb);
        return modelMap;
    }
    @RequestMapping("/querybyid")
    private Map<String,Object> queryById(int id)
    {
        Map<String,Object> modelMap = new HashMap<String,Object>();
        Bj bj = bjService.queryById(id);
        modelMap.put("BjList",bj);
        return modelMap;
    }
    @RequestMapping("/add")
    private Map<String,Object> addBj(@RequestBody Bj bj)
    {
        Map<String,Object> modelMap = new HashMap<String,Object>();
        modelMap.put("success   ",bjService.insertBj(bj));
        return modelMap;
    }
    @RequestMapping("/update")
    private Map<String,Object> updateBj(@RequestBody Bj bj)
    {
        Map<String,Object> modelMap = new HashMap<String,Object>();
        modelMap.put("success",bjService.updateBj(bj));
        return modelMap;
    }
    @RequestMapping("/del")
    private Map<String,Object> delBj(int id)
    {
        Map<String,Object> modelMap = new HashMap<String,Object>();
        modelMap.put("success",bjService.deleteBj(id));
        return modelMap;
    }

}
